/**
 * @file   test009.c
 * @brief  Test mixture of 1 SYSTEM, 1 Periodic, and 1 BRR
 * Expected Results: 12000...12000...
 */
#include "../header/common.h"
#include "../header/os.h"
#include "../header/uart.h"
#include "../header/trace.h"

#ifdef test009

const unsigned char PPP[] = {1,3};
const unsigned int PT = sizeof(PPP)/2;
EVENT* print_event;
extern uint16_t trace_counter;

void generic_task(void)
{
	int arg = 0;
	arg = Task_GetArg();
	for (;;) {
		add_to_trace(arg);
		Task_Next();
	}
}

void system_task(void)
{
	int arg = 0;
	arg = Task_GetArg();

	add_to_trace(arg);
	Task_Next();
}

void periodic_task(void)
{
	int arg = 0;
	arg = Task_GetArg();

	for (;;) {
		add_to_trace(arg);
		Task_Create(system_task,2,SYSTEM,2);
		Task_Next();
	}
}

int main(void) {
	UART_BPS bitrate = UART_38400;
	uart_init(bitrate);

    print_event = Event_Init();

    Task_Create(periodic_task,1,PERIODIC,1);
    Task_Create(generic_task,0, BRR, 1);

    Event_Wait(print_event);
    print_trace();
    return 0;
}

#endif
